<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>更换背景</title>

    <style>
        img {
            width: 100px;
            height: 100px;
            margin: 10px;
        }
        
        body {
            background: url(images/1576555085-aJjSPZCfVI.jpeg) no-repeat center top;
        }
    </style>

</head>

<body>

    <div style="margin: 100px auto;text-align: center;">
        <img src="images/1576555085-aJjSPZCfVI.jpeg"> <img src="images/1576560206-QHYIrJXZPW.jpg"> <img src="images/1578489987-dbtmusgNeA.jpeg">
        <img src="images/827ab178e0057876acff6005791c680e1c0e38bb.jpg">
    </div>



</body>

<script>
    var imgs = document.getElementsByTagName('img');


    for (var i = 0; i < imgs.length; i++) {

        imgs[i].onclick = function() {

            document.body.style.background = 'url(' + this.src + ') no-repeat center top'
        }

    }
</script>

</html>